

function say() {
    alert("LC:933. 最近的请求次数");
}
say();

var RecentCounter = function() {
    //50-05
    this.arr = []
};

/**
 * @param {number} t
 * @return {number}
 */
RecentCounter.prototype.ping = function(t) {
    this.arr.push(t)
    var range = [t - 3000, t]
    // var res = 0
    // for(var i = 0; i < this.arr.length; i++){
    //     var item = this.arr[i]
    //     if(item >= range[0] && item <= t){
    //         res++
    //     }
    // }
    // return res

    while(this.arr[0] < t - 3000){
        this.arr.shift()
    }
    return this.arr.length
};

/**
 * Your RecentCounter object will be instantiated and called as such:
 * var obj = new RecentCounter()
 * var param_1 = obj.ping(t)
 */
